<template>
  <!-- 系统整体页面布局 -->
  <el-container class="el-container">
    <!-- 页面头部区域 高度默认60px -->
    <el-header class="el-header">
      <!-- 应用名称 -->
      <span>火炬区生态环境大数据综合平台</span>
      <el-button
        style="
          background-color: #4356cf;
          color: #fff;
          position: absolute;
          right: 10px;
          border: none;
        "
        size="small"
        @click="loginOut"
        >退出登录</el-button
      >
    </el-header>
    <el-container>
      <!-- 左侧菜单栏部分 -->
      <el-aside class="el-aside">
        <el-menu
          class="el-menu"
          background-color="#32323a"
          :unique-opened="true"
          :default-active="$route.path"
          text-color="#ffffff"
          router
        >
          <MenuTree :menuList="menuList"></MenuTree>
        </el-menu>
      </el-aside>
      <!-- 右侧主题页面内容展示 -->
      <el-main class="el-mian">
        <!-- 路由页面 -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import MenuTree from "@/components/menu/menustree.vue";
import Cookies from "js-cookie";
export default {
  components: {
    MenuTree,
  },
  data() {
    return {
      menuList: [
        {
          id: 1,
          parentid: "0",
          name: "首页",
          icon: "el-icon-s-home",
          url: "/home",
        },
        {
          id: 2,
          parentid: "0",
          name: "项目管理",
          icon: "el-icon-s-unfold",
          children: [
            {
              id: 3,
              parentid: "2",
              name: "扬尘设备管理",
              icon: "",
              url: "/raise-dust",
            },
            {
              id: 5,
              parentid: "2",
              name: "视频监控设备管理",
              icon: "",
              url: "/video",
            },
            {
              id: 6,
              parentid: "2",
              name: "恶臭监测数据",
              icon: "",
              url: "/stink",
            },
            {
              id: 7,
              parentid: "2",
              name: "voc监测数据",
              icon: "",
              url: "/voc",
            },
          ],
        },
      ],
    };
  },
  methods: {
    loginOut() {
      this.$confirm("确认退出登录?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          Cookies.remove("token");
          setTimeout(() => {
            this.$router.push("/login");
          }, 1000);
        })
        .catch(() => {});
    },
  },
};
</script>

<style lang="less" scoped>
/*铺满屏幕，没有边距*/
.el-container {
  padding: 0px;
  margin: 0px;
  width: 100%;
  height: 100vh;
  background-color: #eaedf1;
}
.el-header {
  /* 顶部部分的高度(默认60px) */
  background-color: #0077d5;
  color: #ffffff;
  font-size: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px !important;
}
.el-aside {
  width: 200px !important;
  background-color: #32323a;
  height: calc(100vh - 60px);
  overflow: hidden !important;
}

.el-menu {
  width: 200px;
  min-height: 100%;
}

.el-menu span {
  /* margin-left: 10px; */
}

.el-mian {
  margin: 15px;
  background-color: #fff;
  height: calc(100vh - 90px);
  position: relative;
}
</style>
